//////////////////////////////////////////////////////////////////////////
public:
	/// <summary>
	/// </summary>
	/// <param name="srcarr"></param>
	/// <param name="dstarr"></param>
	/// <param name="canny_threshold"></param>
	/// <param name="ffill_threshold"></param>
	/// <returns></returns>
	static ManagedSeq^ SegmentImage(ManagedArr^ srcarr, ManagedArr^ dstarr, double canny_threshold, double ffill_threshold, ManagedMemStorage^ storage)
	{
		return gcnew ManagedSeq(cvSegmentImage(srcarr->ToCvArrPointer(), dstarr->ToCvArrPointer(), canny_threshold, ffill_threshold, storage->ToCvMemStoragePointer()));
	}

	/// <summary>
	/// Calculates covariation matrix of a set of arrays
	/// </summary>
	/// <param name="nObjects"></param>
	/// <param name="input"></param>
	/// <param name="ioFlags"></param>
	/// <param name="ioBufSize"></param>
	/// <param name="buffer"></param>
	/// <param name="userData"></param>
	/// <param name="avg"></param>
	static void CalcCovarMatrixEx(int nObjects, ManagedEigenInput^ input, EigenObjectIOFlag ioFlags, int ioBufSize, IntPtr buffer, IntPtr userData, ManagedImage^ avg, array<float>^ covarMatrix)
	{
		pin_ptr<float> pcovarMatrix = &covarMatrix[0];
		cvCalcCovarMatrixEx(nObjects, input->ToCvInputPointer(), (int)ioFlags, ioBufSize, (uchar*)buffer.ToPointer(), (void*)userData.ToPointer(), avg->ToIplImagePointer(), pcovarMatrix);
	}

	/// <summary>
	/// Calculates eigen values and vectors of covariation matrix of a set of
	/// arrays
	/// </summary>
	/// <param name="nObjects"></param>
	/// <param name="input"></param>
	/// <param name="output"></param>
	/// <param name="ioFlags"></param>
	/// <param name="ioBufSize"></param>
	/// <param name="userData"></param>
	/// <param name="calcLimit"></param>
	/// <param name="avg"></param>
	static void CalcEigenObjects(int nObjects, ManagedEigenInput^ input, ManagedEigenInput^ output, EigenObjectIOFlag ioFlags, int ioBufSize, IntPtr userData, NAMESPACE::TermCriteria% calcLimit, ManagedImage^ avg, array<float>^ eigVals)
	{
		pin_ptr<NAMESPACE::TermCriteria> pcalcLimit = &calcLimit;
		pin_ptr<float> peigVals = &eigVals[0];
		cvCalcEigenObjects(nObjects, input->ToCvInputPointer(), output->ToCvInputPointer(), (int)ioFlags, ioBufSize, (void*)userData.ToPointer(), (CvTermCriteria*)pcalcLimit, avg->ToIplImagePointer(), peigVals);
	}

	/// <summary>
	/// Calculates dot product (obj - avg) * eigObj (i.e. projects image to eigen vector)
	/// </summary>
	/// <param name="obj"></param>
	/// <param name="eigObj"></param>
	/// <returns></returns>
	static double CalcDecompCoeff(ManagedImage^ obj, ManagedImage^ eigObj, ManagedImage^ avg)
	{
		return cvCalcDecompCoeff(obj->ToIplImagePointer(), eigObj->ToIplImagePointer(), avg->ToIplImagePointer());
	}

	/// <summary>
	/// Projects image to eigen space (finds all decomposion coefficients
	/// </summary>
	/// <param name="obj"></param>
	/// <param name="nEigObjs"></param>
	/// <param name="eigInput"></param>
	/// <param name="ioFlags"></param>
	/// <param name="userData"></param>
	/// <param name="avg"></param>
	static void EigenDecomposite(ManagedImage^ obj, int nEigObjs, ManagedEigenInput^ eigInput, EigenObjectIOFlag ioFlags, IntPtr userData, ManagedImage^ avg, array<float>^ coeffs)
	{
		pin_ptr<float> pcoeffs = &coeffs[0];
		cvEigenDecomposite(obj->ToIplImagePointer(), nEigObjs, eigInput->ToCvInputPointer(), (int)ioFlags, (void*)userData.ToPointer(), avg->ToIplImagePointer(), pcoeffs);
	}

	/// <summary>
	/// Projects original objects used to calculate eigen space basis to that space
	/// </summary>
	/// <param name="eigInput"></param>
	/// <param name="nEigObjs"></param>
	/// <param name="ioFlags"></param>
	/// <param name="userData"></param>
	/// <param name="coeffs"></param>
	/// <param name="avg"></param>
	static void EigenProjection(ManagedEigenInput^ eigInput, int nEigObjs, EigenObjectIOFlag ioFlags, IntPtr userData, array<float>^ coeffs, ManagedImage^ avg, ManagedImage^ proj)
	{
		pin_ptr<float> pcoeffs = &coeffs[0];
		cvEigenProjection(eigInput->ToCvInputPointer(), nEigObjs, (int)ioFlags, (void*)userData.ToPointer(), pcoeffs, avg->ToIplImagePointer(), proj->ToIplImagePointer());
	}

	/// <summary>
	/// Creates 2D HMM
	/// </summary>
	/// <param name="stateNumber"></param>
	/// <param name="numMix"></param>
	/// <returns></returns>
	static ManagedEHMM^ Create2DHMM(array<int>^ stateNumber, array<int>^ numMix, int obsSize)
	{
		pin_ptr<int> pstateNumber = &stateNumber[0];
		pin_ptr<int> pnumMix = &numMix[0];
		return gcnew ManagedEHMM(cvCreate2DHMM(pstateNumber, pnumMix, obsSize), true);
	}

	/// <summary>
	/// Releases HMM
	/// </summary>
	static void Release2DHMM(ManagedEHMM^% hmm)
	{
		CvEHMM* pEHMM = hmm->ToCvEHMMPointer();
		cvRelease2DHMM(&pEHMM);
		hmm->m_pHandle = pEHMM;
	}

	/// <summary>
	/// Creates storage for observation vectors
	/// </summary>
	/// <param name="numObs"></param>
	/// <returns></returns>
	static ManagedImgObsInfo^ CreateObsInfo(NAMESPACE::Size2D32s numObs, int obsSize)
	{
		return gcnew ManagedImgObsInfo(cvCreateObsInfo(*(CvSize*)&numObs, obsSize), true);
	}

	/// <summary>
	/// Releases storage for observation vectors
	/// </summary>
	static void ReleaseObsInfo(ManagedImgObsInfo^% obs_info)
	{
		CvImgObsInfo* pImgObsInfo = obs_info->ToCvImgObsInfoPointer();
		cvReleaseObsInfo(&pImgObsInfo);
		obs_info->m_pHandle = pImgObsInfo;
	}

	/// <summary>
	/// The function takes an image on input and and returns the sequnce of observations
	/// to be used with an embedded HMM; Each observation is top-left block of DCT
	/// coefficient matrix
	/// </summary>
	/// <param name="arr"></param>
	/// <param name="obs"></param>
	/// <param name="dctSize"></param>
	/// <param name="obsSize"></param>
	static void ImgToObs_DCT(ManagedArr^ arr, array<float>^ obs, NAMESPACE::Size2D32s dctSize, NAMESPACE::Size2D32s obsSize, NAMESPACE::Size2D32s delta)
	{
		pin_ptr<float> pobs = &obs[0];
		cvImgToObs_DCT(arr->ToCvArrPointer(), pobs, *(CvSize*)&dctSize, *(CvSize*)&obsSize, *(CvSize*)&delta);
	}

	/// <summary>
	/// Uniformly segments all observation vectors extracted from image
	/// </summary>
	/// <param name="obs_info"></param>
	static void UniformImgSegm(ManagedImgObsInfo^ obs_info, ManagedEHMM^ ehmm)
	{
		cvUniformImgSegm(obs_info->ToCvImgObsInfoPointer(), ehmm->ToCvEHMMPointer());
	}

	/// <summary>
	/// Does mixture segmentation of the states of embedded HMM
	/// </summary>
	/// <param name="obs_info_array"></param>
	/// <param name="num_img"></param>
	static void InitMixSegm(array<ManagedImgObsInfo^>^ obs_info_array, int num_img, ManagedEHMM^ hmm)
	{
		vector<CvImgObsInfo*> vobs_info_array(num_img);
		for (int i = 0; i < num_img; i++)
		{
			vobs_info_array[i] = obs_info_array[i]->ToCvImgObsInfoPointer();
		}
		cvInitMixSegm(&vobs_info_array[0], num_img, hmm->ToCvEHMMPointer());
	}

	/// <summary>
	/// Function calculates means, variances, weights of every Gaussian mixture
	/// of every low-level state of embedded HMM
	/// </summary>
	/// <param name="obs_info_array"></param>
	/// <param name="num_img"></param>
	static void EstimateHMMStateParams(array<ManagedImgObsInfo^>^ obs_info_array, int num_img, ManagedEHMM^ hmm)
	{
		vector<CvImgObsInfo*> vobs_info_array(num_img);
		for (int i = 0; i < num_img; i++)
		{
			vobs_info_array[i] = obs_info_array[i]->ToCvImgObsInfoPointer();
		}
		cvEstimateHMMStateParams(&vobs_info_array[0], num_img, hmm->ToCvEHMMPointer());
	}

	/// <summary>
	/// Function computes transition probability matrices of embedded HMM
	/// given observations segmentation
	/// </summary>
	/// <param name="obs_info_array"></param>
	/// <param name="num_img"></param>
	static void EstimateTransProb(array<ManagedImgObsInfo^>^ obs_info_array, int num_img, ManagedEHMM^ hmm)
	{
		vector<CvImgObsInfo*> vobs_info_array(num_img);
		for (int i = 0; i < num_img; i++)
		{
			vobs_info_array[i] = obs_info_array[i]->ToCvImgObsInfoPointer();
		}
		cvEstimateTransProb(&vobs_info_array[0], num_img, hmm->ToCvEHMMPointer());
	}

	/// <summary>
	/// Function computes probabilities of appearing observations at any state
	/// (i.e. computes P(obs|state) for every pair(obs,state))
	/// </summary>
	/// <param name="obs_info"></param>
	static void EstimateObsProb(ManagedImgObsInfo^ obs_info, ManagedEHMM^ hmm)
	{
		cvEstimateObsProb(obs_info->ToCvImgObsInfoPointer(), hmm->ToCvEHMMPointer());
	}

	/// <summary>
	/// Runs Viterbi algorithm for embedded HMM
	/// </summary>
	/// <param name="obs_info"></param>
	/// <returns></returns>
	static float EViterbi(ManagedImgObsInfo^ obs_info, ManagedEHMM^ hmm)
	{
		return cvEViterbi(obs_info->ToCvImgObsInfoPointer(), hmm->ToCvEHMMPointer());
	}

	/// <summary>
	/// Function clusters observation vectors from several images
	/// given observations segmentation.
	/// Euclidean distance used for clustering vectors.
	/// Centers of clusters are given means of every mixture
	/// </summary>
	/// <param name="obs_info_array"></param>
	/// <param name="num_img"></param>
	static void MixSegmL2(array<ManagedImgObsInfo^>^ obs_info_array, int num_img, ManagedEHMM^ hmm)
	{
		vector<CvImgObsInfo*> vobs_info_array(num_img);
		for (int i = 0; i < num_img; i++)
		{
			vobs_info_array[i] = obs_info_array[i]->ToCvImgObsInfoPointer();
		}
		cvMixSegmL2(&vobs_info_array[0], num_img, hmm->ToCvEHMMPointer());
	}

	/// <summary>
	/// Creates hand mask image given several points on the hand
	/// </summary>
	/// <param name="hand_points"></param>
	/// <param name="img_mask"></param>
	static void CreateHandMask(ManagedSeq^ hand_points, ManagedImage^ img_mask, [OutAttribute] NAMESPACE::Rect% roi)
	{
		pin_ptr<NAMESPACE::Rect> proi = &roi;
		cvCreateHandMask(hand_points->ToCvSeqPointer(), img_mask->ToIplImagePointer(), (CvRect*)proi);
	}

	/// <summary>
	/// Finds hand region in range image data
	/// </summary>
	/// <param name="points"></param>
	/// <param name="count"></param>
	/// <param name="indexs"></param>
	/// <param name="line"></param>
	/// <param name="size"></param>
	/// <param name="flag"></param>
	/// <param name="center"></param>
	/// <param name="storage"></param>
	static void FindHandRegion(array<NAMESPACE::Point3D32f>^ points, int count, ManagedSeq^ indexs, array<float>^ line, NAMESPACE::Size2D32f size, int flag, [OutAttribute] NAMESPACE::Point3D32f% center, ManagedMemStorage^ storage, [OutAttribute] ManagedSeq^% numbers)
	{
		pin_ptr<NAMESPACE::Point3D32f> ppoints = &points[0];
		pin_ptr<float> pline = &line[0];
		pin_ptr<NAMESPACE::Point3D32f> pcenter = &center;
		CvSeq* pnumbers = NULL;
		cvFindHandRegion((CvPoint3D32f*)ppoints, count, indexs->ToCvSeqPointer(), pline, *(CvSize2D32f*)&size, flag, (CvPoint3D32f*)pcenter, storage->ToCvMemStoragePointer(), &pnumbers);
		numbers = gcnew ManagedSeq(pnumbers);
	}

	/// <summary>
	/// Finds hand region in range image data (advanced version)
	/// </summary>
	/// <param name="points"></param>
	/// <param name="count"></param>
	/// <param name="indexs"></param>
	/// <param name="line"></param>
	/// <param name="size"></param>
	/// <param name="jc"></param>
	/// <param name="center"></param>
	/// <param name="storage"></param>
	static void FindHandRegionA(array<NAMESPACE::Point3D32f>^ points, int count, ManagedSeq^ indexs, array<float>^ line, NAMESPACE::Size2D32f size, int jc, [OutAttribute] NAMESPACE::Point3D32f% center, ManagedMemStorage^ storage, [OutAttribute] ManagedSeq^% numbers)
	{
		pin_ptr<NAMESPACE::Point3D32f> ppoints = &points[0];
		pin_ptr<float> pline = &line[0];
		pin_ptr<NAMESPACE::Point3D32f> pcenter = &center;
		CvSeq* pnumbers = NULL;
		cvFindHandRegionA((CvPoint3D32f*)ppoints, count, indexs->ToCvSeqPointer(), pline, *(CvSize2D32f*)&size, jc, (CvPoint3D32f*)pcenter, storage->ToCvMemStoragePointer(), &pnumbers);
		numbers = gcnew ManagedSeq(pnumbers);
	}

	/// <summary>
	/// Additional operations on Subdivisions
	/// </summary>
	/// <param name="subdiv"></param>
	/// <param name="src"></param>
	static void DrawMosaic(ManagedSubdiv2D^ subdiv, ManagedImage^ src, ManagedImage^ dst)
	{
		icvDrawMosaic(subdiv->ToCvSubdiv2DPointer(), src->ToIplImagePointer(), dst->ToIplImagePointer());
	}

	/// <summary>
	/// checks planar subdivision for correctness. It is not an absolute check,
	/// but it verifies some relations between quad-edges
	/// </summary>
	/// <returns></returns>
	static int Subdiv2DCheck(ManagedSubdiv2D^ subdiv)
	{
		return icvSubdiv2DCheck(subdiv->ToCvSubdiv2DPointer());
	}

	/// <summary>
	///   Name:    cvFindStereoCorrespondence
	///   Purpose: find stereo correspondence on stereo-pair
	///   Context:
	///   Parameters:
	///     leftImage - left image of stereo-pair (format 8uC1).
	///     rightImage - right image of stereo-pair (format 8uC1).
	///  mode - mode of correspondence retrieval (now CV_DISPARITY_BIRCHFIELD only)
	///     dispImage - destination disparity image
	///     maxDisparity - maximal disparity
	///     param1, param2, param3, param4, param5 - parameters of algorithm
	///   Returns:
	///   Notes:
	///     Images must be rectified.
	///     All images must have format 8uC1.
	/// //F
	/// </summary>
	/// <param name="leftImage"></param>
	/// <param name="rightImage"></param>
	/// <param name="mode"></param>
	/// <param name="dispImage"></param>
	/// <param name="maxDisparity"></param>
	/// <param name="param1"></param>
	/// <param name="param2"></param>
	/// <param name="param3"></param>
	/// <param name="param4"></param>
	static void FindStereoCorrespondence(ManagedArr^ leftImage, ManagedArr^ rightImage, CorrespondenceRetrievalMode mode, ManagedArr^ dispImage, int maxDisparity, double param1, double param2, double param3, double param4, double param5)
	{
		cvFindStereoCorrespondence(leftImage->ToCvArrPointer(), rightImage->ToCvArrPointer(), (int)mode, dispImage->ToCvArrPointer(), maxDisparity, param1, param2, param3, param4, param5);
	}

	/// <summary>
	///   Name:    cvFindStereoCorrespondence
	///   Purpose: find stereo correspondence on stereo-pair
	///   Context:
	///   Parameters:
	///     leftImage - left image of stereo-pair (format 8uC1).
	///     rightImage - right image of stereo-pair (format 8uC1).
	///  mode - mode of correspondence retrieval (now CV_DISPARITY_BIRCHFIELD only)
	///     dispImage - destination disparity image
	///     maxDisparity - maximal disparity
	///     param1, param2, param3, param4, param5 - parameters of algorithm
	///   Returns:
	///   Notes:
	///     Images must be rectified.
	///     All images must have format 8uC1.
	/// //F
	/// </summary>
	/// <param name="leftImage"></param>
	/// <param name="rightImage"></param>
	/// <param name="mode"></param>
	/// <param name="dispImage"></param>
	/// <param name="maxDisparity"></param>
	/// <param name="param1"></param>
	/// <param name="param2"></param>
	/// <param name="param3"></param>
	static void FindStereoCorrespondence(ManagedArr^ leftImage, ManagedArr^ rightImage, CorrespondenceRetrievalMode mode, ManagedArr^ dispImage, int maxDisparity, double param1, double param2, double param3, double param4)
	{
		cvFindStereoCorrespondence(leftImage->ToCvArrPointer(), rightImage->ToCvArrPointer(), (int)mode, dispImage->ToCvArrPointer(), maxDisparity, param1, param2, param3, param4);
	}

	/// <summary>
	/// F///////////////////////////////////////////////////////////////////////////
	/// //
	///   Name:    cvFindStereoCorrespondence
	///   Purpose: find stereo correspondence on stereo-pair
	///   Context:
	///   Parameters:
	///     leftImage - left image of stereo-pair (format 8uC1).
	///     rightImage - right image of stereo-pair (format 8uC1).
	///  mode - mode of correspondence retrieval (now CV_DISPARITY_BIRCHFIELD only)
	///     dispImage - destination disparity image
	///     maxDisparity - maximal disparity
	///     param1, param2, param3, param4, param5 - parameters of algorithm
	///   Returns:
	///   Notes:
	///     Images must be rectified.
	///     All images must have format 8uC1.
	/// //F
	/// </summary>
	/// <param name="leftImage"></param>
	/// <param name="rightImage"></param>
	/// <param name="mode"></param>
	/// <param name="dispImage"></param>
	/// <param name="maxDisparity"></param>
	/// <param name="param1"></param>
	/// <param name="param2"></param>
	static void FindStereoCorrespondence(ManagedArr^ leftImage, ManagedArr^ rightImage, CorrespondenceRetrievalMode mode, ManagedArr^ dispImage, int maxDisparity, double param1, double param2, double param3)
	{
		cvFindStereoCorrespondence(leftImage->ToCvArrPointer(), rightImage->ToCvArrPointer(), (int)mode, dispImage->ToCvArrPointer(), maxDisparity, param1, param2, param3);
	}

	/// <summary>
	/// F///////////////////////////////////////////////////////////////////////////
	/// //
	///   Name:    cvFindStereoCorrespondence
	///   Purpose: find stereo correspondence on stereo-pair
	///   Context:
	///   Parameters:
	///     leftImage - left image of stereo-pair (format 8uC1).
	///     rightImage - right image of stereo-pair (format 8uC1).
	///  mode - mode of correspondence retrieval (now CV_DISPARITY_BIRCHFIELD only)
	///     dispImage - destination disparity image
	///     maxDisparity - maximal disparity
	///     param1, param2, param3, param4, param5 - parameters of algorithm
	///   Returns:
	///   Notes:
	///     Images must be rectified.
	///     All images must have format 8uC1.
	/// //F
	/// </summary>
	/// <param name="leftImage"></param>
	/// <param name="rightImage"></param>
	/// <param name="mode"></param>
	/// <param name="dispImage"></param>
	/// <param name="maxDisparity"></param>
	/// <param name="param1"></param>
	static void FindStereoCorrespondence(ManagedArr^ leftImage, ManagedArr^ rightImage, CorrespondenceRetrievalMode mode, ManagedArr^ dispImage, int maxDisparity, double param1, double param2)
	{
		cvFindStereoCorrespondence(leftImage->ToCvArrPointer(), rightImage->ToCvArrPointer(), (int)mode, dispImage->ToCvArrPointer(), maxDisparity, param1, param2);
	}

	/// <summary>
	/// F///////////////////////////////////////////////////////////////////////////
	/// //
	///   Name:    cvFindStereoCorrespondence
	///   Purpose: find stereo correspondence on stereo-pair
	///   Context:
	///   Parameters:
	///     leftImage - left image of stereo-pair (format 8uC1).
	///     rightImage - right image of stereo-pair (format 8uC1).
	///  mode - mode of correspondence retrieval (now CV_DISPARITY_BIRCHFIELD only)
	///     dispImage - destination disparity image
	///     maxDisparity - maximal disparity
	///     param1, param2, param3, param4, param5 - parameters of algorithm
	///   Returns:
	///   Notes:
	///     Images must be rectified.
	///     All images must have format 8uC1.
	/// //F
	/// </summary>
	/// <param name="leftImage"></param>
	/// <param name="rightImage"></param>
	/// <param name="mode"></param>
	/// <param name="dispImage"></param>
	/// <param name="maxDisparity"></param>
	static void FindStereoCorrespondence(ManagedArr^ leftImage, ManagedArr^ rightImage, CorrespondenceRetrievalMode mode, ManagedArr^ dispImage, int maxDisparity, double param1)
	{
		cvFindStereoCorrespondence(leftImage->ToCvArrPointer(), rightImage->ToCvArrPointer(), (int)mode, dispImage->ToCvArrPointer(), maxDisparity, param1);
	}

	/// <summary>
	/// F///////////////////////////////////////////////////////////////////////////
	/// //
	///   Name:    cvFindStereoCorrespondence
	///   Purpose: find stereo correspondence on stereo-pair
	///   Context:
	///   Parameters:
	///     leftImage - left image of stereo-pair (format 8uC1).
	///     rightImage - right image of stereo-pair (format 8uC1).
	///  mode - mode of correspondence retrieval (now CV_DISPARITY_BIRCHFIELD only)
	///     dispImage - destination disparity image
	///     maxDisparity - maximal disparity
	///     param1, param2, param3, param4, param5 - parameters of algorithm
	///   Returns:
	///   Notes:
	///     Images must be rectified.
	///     All images must have format 8uC1.
	/// //F
	/// </summary>
	/// <param name="leftImage"></param>
	/// <param name="rightImage"></param>
	/// <param name="mode"></param>
	/// <param name="dispImage"></param>
	static void FindStereoCorrespondence(ManagedArr^ leftImage, ManagedArr^ rightImage, CorrespondenceRetrievalMode mode, ManagedArr^ dispImage, int maxDisparity)
	{
		cvFindStereoCorrespondence(leftImage->ToCvArrPointer(), rightImage->ToCvArrPointer(), (int)mode, dispImage->ToCvArrPointer(), maxDisparity);
	}

	/// <summary>
	/// </summary>
	/// <param name="coeffs[3][3]"></param>
	/// <param name="cameraPoint"></param>
	/// <param name="warpPoint"></param>
	/// <returns></returns>
	static int ConvertWarpCoordinates(array<double, 2>^ coeffs, NAMESPACE::Point2D32f% cameraPoint, NAMESPACE::Point2D32f% warpPoint, ConvertWarpDirection direction)
	{
		double _coeffs[3][3];
		_coeffs[0][0] = coeffs[0, 0];
		_coeffs[0][1] = coeffs[0, 1];
		_coeffs[0][2] = coeffs[0, 2];
		_coeffs[1][0] = coeffs[1, 0];
		_coeffs[1][1] = coeffs[1, 1];
		_coeffs[1][2] = coeffs[1, 2];
		_coeffs[2][0] = coeffs[2, 0];
		_coeffs[2][1] = coeffs[2, 1];
		_coeffs[2][2] = coeffs[2, 2];
		pin_ptr<NAMESPACE::Point2D32f> pcameraPoint = &cameraPoint;
		pin_ptr<NAMESPACE::Point2D32f> pwarpPoint = &warpPoint;
		return icvConvertWarpCoordinates(_coeffs, (CvPoint2D32f*)pcameraPoint, (CvPoint2D32f*)pwarpPoint, (int)direction);
	}

	/// <summary>
	/// </summary>
	/// <param name="pointCorner"></param>
	/// <param name="point1"></param>
	/// <param name="point2"></param>
	/// <returns></returns>
	static int GetSymPoint3D(NAMESPACE::Point3D64f pointCorner, NAMESPACE::Point3D64f point1, NAMESPACE::Point3D64f point2, [OutAttribute] NAMESPACE::Point3D64f% pointSym2)
	{
		pin_ptr<NAMESPACE::Point3D64f> ppointSym2 = &pointSym2;
		return icvGetSymPoint3D(*(CvPoint3D64f*)&pointCorner, *(CvPoint3D64f*)&point1, *(CvPoint3D64f*)&point2, (CvPoint3D64f*)ppointSym2);
	}

	/// <summary>
	/// </summary>
	/// <param name="point1"></param>
	/// <param name="point2"></param>
	static void GetPieceLength3D(NAMESPACE::Point3D64f point1, NAMESPACE::Point3D64f point2, [OutAttribute] double% dist)
	{
		pin_ptr<double> pdist = &dist;
		icvGetPieceLength3D(*(CvPoint3D64f*)&point1, *(CvPoint3D64f*)&point2, pdist);
	}

	/// <summary>
	/// </summary>
	/// <param name="alpha"></param>
	/// <param name="betta"></param>
	/// <param name="coeffs"></param>
	/// <returns></returns>
	static int Compute3DPoint(double alpha, double betta, NAMESPACE::StereoLineCoeff% coeffs, [OutAttribute] NAMESPACE::Point3D64f% point)
	{
		pin_ptr<NAMESPACE::StereoLineCoeff> pcoeffs = &coeffs;
		pin_ptr<NAMESPACE::Point3D64f> ppoint = &point;
		return icvCompute3DPoint(alpha, betta, (CvStereoLineCoeff*)pcoeffs, (CvPoint3D64f*)ppoint);
	}

	/// <summary>
	/// </summary>
	/// <param name="rotMatr1"></param>
	/// <param name="transVect1"></param>
	/// <param name="rotMatr2"></param>
	/// <param name="transVect2"></param>
	/// <param name="convRotMatr"></param>
	/// <returns></returns>
	static int CreateConvertMatrVect(array<double>^ rotMatr1, array<double>^ transVect1, array<double>^ rotMatr2, array<double>^ transVect2, array<double>^ convRotMatr, array<double>^ convTransVect)
	{
		pin_ptr<double> protMatr1 = &rotMatr1[0];
		pin_ptr<double> ptransVect1 = &transVect1[0];
		pin_ptr<double> protMatr2 = &rotMatr2[0];
		pin_ptr<double> ptransVect2 = &transVect2[0];
		pin_ptr<double> pconvRotMatr = &convRotMatr[0];
		pin_ptr<double> pconvTransVect = &convTransVect[0];
		return icvCreateConvertMatrVect(protMatr1, ptransVect1, protMatr2, ptransVect2, pconvRotMatr, pconvTransVect);
	}

	/// <summary>
	/// </summary>
	/// <param name="M2"></param>
	/// <param name="M1"></param>
	/// <param name="rotMatr"></param>
	/// <returns></returns>
	static int ConvertPointSystem(NAMESPACE::Point3D64f M2, [OutAttribute] NAMESPACE::Point3D64f% M1, array<double>^ rotMatr, array<double>^ transVect)
	{
		pin_ptr<NAMESPACE::Point3D64f> pM1 = &M1;
		pin_ptr<double> protMatr = &rotMatr[0];
		pin_ptr<double> ptransVect = &transVect[0];
		return icvConvertPointSystem(*(CvPoint3D64f*)&M2, (CvPoint3D64f*)pM1, protMatr, ptransVect);
	}

	/// <summary>
	/// </summary>
	/// <returns></returns>
	static int ComputeCoeffForStereo(ManagedStereoCamera^ stereoCamera)
	{
		return icvComputeCoeffForStereo(stereoCamera->ToCvStereoCameraPointer());
	}

	/// <summary>
	/// </summary>
	/// <param name="p1_start"></param>
	/// <param name="p1_end"></param>
	/// <param name="v2_start"></param>
	/// <param name="v2_end"></param>
	/// <returns></returns>
	static int GetCrossPieceVector(NAMESPACE::Point2D32f p1_start, NAMESPACE::Point2D32f p1_end, NAMESPACE::Point2D32f v2_start, NAMESPACE::Point2D32f v2_end, [OutAttribute] NAMESPACE::Point2D32f% cross)
	{
		pin_ptr<NAMESPACE::Point2D32f> pcross = &cross;
		return icvGetCrossPieceVector(*(CvPoint2D32f*)&p1_start, *(CvPoint2D32f*)&p1_end, *(CvPoint2D32f*)&v2_start, *(CvPoint2D32f*)&v2_end, (CvPoint2D32f*)pcross);
	}

	/// <summary>
	/// </summary>
	/// <param name="p1"></param>
	/// <param name="p2"></param>
	/// <param name="a"></param>
	/// <param name="b"></param>
	/// <param name="c"></param>
	/// <returns></returns>
	static int GetCrossLineDirect(NAMESPACE::Point2D32f p1, NAMESPACE::Point2D32f p2, float a, float b, float c, [OutAttribute] NAMESPACE::Point2D32f% cross)
	{
		pin_ptr<NAMESPACE::Point2D32f> pcross = &cross;
		return icvGetCrossLineDirect(*(CvPoint2D32f*)&p1, *(CvPoint2D32f*)&p2, a, b, c, (CvPoint2D32f*)pcross);
	}

	/// <summary>
	/// </summary>
	/// <param name="point1"></param>
	/// <param name="point2"></param>
	/// <returns></returns>
	static float DefinePointPosition(NAMESPACE::Point2D32f point1, NAMESPACE::Point2D32f point2, NAMESPACE::Point2D32f point)
	{
		return icvDefinePointPosition(*(CvPoint2D32f*)&point1, *(CvPoint2D32f*)&point2, *(CvPoint2D32f*)&point);
	}

	/// <summary>
	/// </summary>
	/// <param name="numImages"></param>
	/// <param name="nums"></param>
	/// <param name="imageSize"></param>
	/// <param name="imagePoints1"></param>
	/// <param name="imagePoints2"></param>
	/// <param name="objectPoints"></param>
	/// <returns></returns>
	static int StereoCalibration(int numImages, array<int>^ nums, NAMESPACE::Size2D32s imageSize, array<NAMESPACE::Point2D32f>^ imagePoints1, array<NAMESPACE::Point2D32f>^ imagePoints2, array<NAMESPACE::Point3D32f>^ objectPoints, ManagedStereoCamera^ stereoparams)
	{
		pin_ptr<int> pnums = &nums[0];
		pin_ptr<NAMESPACE::Point2D32f> pimagePoints1 = &imagePoints1[0];
		pin_ptr<NAMESPACE::Point2D32f> pimagePoints2 = &imagePoints2[0];
		pin_ptr<NAMESPACE::Point3D32f> pobjectPoints = &objectPoints[0];
		return icvStereoCalibration(numImages, pnums, *(CvSize*)&imageSize, (CvPoint2D32f*)pimagePoints1, (CvPoint2D32f*)pimagePoints2, (CvPoint3D32f*)pobjectPoints, stereoparams->ToCvStereoCameraPointer());
	}

	/// <summary>
	/// </summary>
	/// <returns></returns>
	static int ComputeRestStereoParams(ManagedStereoCamera^ stereoparams)
	{
		return icvComputeRestStereoParams(stereoparams->ToCvStereoCameraPointer());
	}

	/// <summary>
	/// </summary>
	/// <param name="coeffs[3][3]"></param>
	/// <param name="rectMapX"></param>
	static void ComputePerspectiveMap(array<double, 2>^ coeffs, ManagedArr^ rectMapX, ManagedArr^ rectMapY)
	{
		double _coeffs[3][3];
		_coeffs[0][0] = coeffs[0, 0];
		_coeffs[0][1] = coeffs[0, 1];
		_coeffs[0][2] = coeffs[0, 2];
		_coeffs[1][0] = coeffs[1, 0];
		_coeffs[1][1] = coeffs[1, 1];
		_coeffs[1][2] = coeffs[1, 2];
		_coeffs[2][0] = coeffs[2, 0];
		_coeffs[2][1] = coeffs[2, 1];
		_coeffs[2][2] = coeffs[2, 2];
		cvComputePerspectiveMap(_coeffs, rectMapX->ToCvArrPointer(), rectMapY->ToCvArrPointer());
	}

	/// <summary>
	/// </summary>
	/// <param name="point1"></param>
	/// <param name="point2"></param>
	/// <param name="point3"></param>
	/// <param name="point4"></param>
	/// <param name="camMatr1"></param>
	/// <param name="rotMatr1"></param>
	/// <param name="transVect1"></param>
	/// <param name="camMatr2"></param>
	/// <param name="rotMatr2"></param>
	/// <param name="transVect2"></param>
	/// <param name="coeffs"></param>
	/// <returns></returns>
	static int ComCoeffForLine(NAMESPACE::Point2D64f point1, NAMESPACE::Point2D64f point2, NAMESPACE::Point2D64f point3, NAMESPACE::Point2D64f point4, array<double>^ camMatr1, array<double>^ rotMatr1, array<double>^ transVect1, array<double>^ camMatr2, array<double>^ rotMatr2, array<double>^ transVect2, [OutAttribute] StereoLineCoeff% coeffs, [OutAttribute] int% needSwapCameras)
	{
		pin_ptr<double> pcamMatr1 = &camMatr1[0];
		pin_ptr<double> protMatr1 = &rotMatr1[0];
		pin_ptr<double> ptransVect1 = &transVect1[0];
		pin_ptr<double> pcamMatr2 = &camMatr2[0];
		pin_ptr<double> protMatr2 = &rotMatr2[0];
		pin_ptr<double> ptransVect2 = &transVect2[0];
		pin_ptr<StereoLineCoeff> pcoeffs = &coeffs;
		pin_ptr<int> pneedSwapCameras = &needSwapCameras;
		return icvComCoeffForLine(*(CvPoint2D64f*)&point1, *(CvPoint2D64f*)&point2, *(CvPoint2D64f*)&point3, *(CvPoint2D64f*)&point4, pcamMatr1, protMatr1, ptransVect1, pcamMatr2, protMatr2, ptransVect2, (CvStereoLineCoeff*)pcoeffs, pneedSwapCameras);
	}

	/// <summary>
	/// </summary>
	/// <param name="point"></param>
	/// <param name="camMatr"></param>
	/// <returns></returns>
	static int GetDirectionForPoint(NAMESPACE::Point2D64f point, array<double>^ camMatr, [OutAttribute] NAMESPACE::Point3D64f% direct)
	{
		pin_ptr<double> pcamMatr = &camMatr[0];
		pin_ptr<NAMESPACE::Point3D64f> pdirect = &direct;
		return icvGetDirectionForPoint(*(CvPoint2D64f*)&point, pcamMatr, (CvPoint3D64f*)pdirect);
	}

	/// <summary>
	/// </summary>
	/// <param name="point11"></param>
	/// <param name="point12"></param>
	/// <param name="point21"></param>
	/// <param name="point22"></param>
	/// <returns></returns>
	static int GetCrossLines(NAMESPACE::Point3D64f point11, NAMESPACE::Point3D64f point12, NAMESPACE::Point3D64f point21, NAMESPACE::Point3D64f point22, [OutAttribute] NAMESPACE::Point3D64f% midPoint)
	{
		pin_ptr<NAMESPACE::Point3D64f> pmidPoint = &midPoint;
		return icvGetCrossLines(*(CvPoint3D64f*)&point11, *(CvPoint3D64f*)&point12, *(CvPoint3D64f*)&point21, *(CvPoint3D64f*)&point22, (CvPoint3D64f*)pmidPoint);
	}

	/// <summary>
	/// </summary>
	/// <param name="pointA"></param>
	/// <param name="pointB"></param>
	/// <param name="pointCam1"></param>
	/// <param name="gamma"></param>
	/// <returns></returns>
	static int ComputeStereoLineCoeffs(NAMESPACE::Point3D64f pointA, NAMESPACE::Point3D64f pointB, NAMESPACE::Point3D64f pointCam1, double gamma, [OutAttribute] StereoLineCoeff% coeffs)
	{
		pin_ptr<StereoLineCoeff> pcoeffs = &coeffs;
		return icvComputeStereoLineCoeffs(*(CvPoint3D64f*)&pointA, *(CvPoint3D64f*)&pointB, *(CvPoint3D64f*)&pointCam1, gamma, (CvStereoLineCoeff*)pcoeffs);
	}

	/// <summary>
	/// </summary>
	/// <param name="startPoint"></param>
	/// <param name="imageSize"></param>
	/// <param name="point1"></param>
	/// <returns></returns>
	static int GetAngleLine(NAMESPACE::Point2D64f startPoint, NAMESPACE::Size2D32s imageSize, [OutAttribute] NAMESPACE::Point2D64f% point1, [OutAttribute] NAMESPACE::Point2D64f% point2)
	{
		pin_ptr<NAMESPACE::Point2D64f> ppoint1 = &point1;
		pin_ptr<NAMESPACE::Point2D64f> ppoint2 = &point2;
		return icvGetAngleLine(*(CvPoint2D64f*)&startPoint, *(CvSize*)&imageSize, (CvPoint2D64f*)ppoint1, (CvPoint2D64f*)ppoint2);
	}

	/// <summary>
	/// </summary>
	/// <param name="p_start"></param>
	/// <param name="p_end"></param>
	/// <param name="a"></param>
	/// <param name="b"></param>
	/// <param name="c"></param>
	static void GetCoefForPiece(NAMESPACE::Point2D64f p_start, NAMESPACE::Point2D64f p_end, [OutAttribute] double% a, [OutAttribute] double% b, [OutAttribute] double% c, [OutAttribute] int% result)
	{
		pin_ptr<double> pa = &a;
		pin_ptr<double> pb = &b;
		pin_ptr<double> pc = &c;
		pin_ptr<int> presult = &result;
		icvGetCoefForPiece(*(CvPoint2D64f*)&p_start, *(CvPoint2D64f*)&p_end, pa, pb, pc, presult);
	}

	/// <summary>
	/// CVAPI(void) icvGetCommonArea( CvSize imageSize,
	/// CvPoint2D64f epipole1,CvPoint2D64f epipole2,
	/// CvMatr64d fundMatr,
	/// CvVect64d coeff11,CvVect64d coeff12,
	/// CvVect64d coeff21,CvVect64d coeff22,
	/// int* result);
	/// </summary>
	/// <param name="rotMatr"></param>
	/// <param name="camMatr1"></param>
	/// <param name="camMatr2"></param>
	/// <param name="point1"></param>
	static void ComputeeInfiniteProject1(array<double>^ rotMatr, array<double>^ camMatr1, array<double>^ camMatr2, NAMESPACE::Point2D32f point1, [OutAttribute] NAMESPACE::Point2D32f% point2)
	{
		pin_ptr<double> protMatr = &rotMatr[0];
		pin_ptr<double> pcamMatr1 = &camMatr1[0];
		pin_ptr<double> pcamMatr2 = &camMatr2[0];
		pin_ptr<NAMESPACE::Point2D32f> ppoint2 = &point2;
		icvComputeeInfiniteProject1(protMatr, pcamMatr1, pcamMatr2, *(CvPoint2D32f*)&point1, (CvPoint2D32f*)ppoint2);
	}

	/// <summary>
	/// </summary>
	/// <param name="rotMatr"></param>
	/// <param name="camMatr1"></param>
	/// <param name="camMatr2"></param>
	/// <param name="point1"></param>
	static void ComputeeInfiniteProject2(array<double>^ rotMatr, array<double>^ camMatr1, array<double>^ camMatr2, [OutAttribute] NAMESPACE::Point2D32f% point1, NAMESPACE::Point2D32f point2)
	{
		pin_ptr<double> protMatr = &rotMatr[0];
		pin_ptr<double> pcamMatr1 = &camMatr1[0];
		pin_ptr<double> pcamMatr2 = &camMatr2[0];
		pin_ptr<NAMESPACE::Point2D32f> ppoint1 = &point1;
		icvComputeeInfiniteProject2(protMatr, pcamMatr1, pcamMatr2, (CvPoint2D32f*)ppoint1, *(CvPoint2D32f*)&point2);
	}

	/// <summary>
	/// </summary>
	/// <param name="direct1"></param>
	/// <param name="direct2"></param>
	/// <param name="cross"></param>
	static void GetCrossDirectDirect(array<double>^ direct1, array<double>^ direct2, [OutAttribute] NAMESPACE::Point2D64f% cross, [OutAttribute] int% result)
	{
		pin_ptr<double> pdirect1 = &direct1[0];
		pin_ptr<double> pdirect2 = &direct2[0];
		pin_ptr<NAMESPACE::Point2D64f> pcross = &cross;
		pin_ptr<int> presult = &result;
		icvGetCrossDirectDirect((CvVect64d)pdirect1, (CvVect64d)pdirect2, (CvPoint2D64f*)pcross, presult);
	}

	/// <summary>
	/// </summary>
	/// <param name="p_start"></param>
	/// <param name="p_end"></param>
	/// <param name="a"></param>
	/// <param name="b"></param>
	/// <param name="c"></param>
	/// <param name="cross"></param>
	static void GetCrossPieceDirect(NAMESPACE::Point2D64f p_start, NAMESPACE::Point2D64f p_end, double a, double b, double c, [OutAttribute] NAMESPACE::Point2D64f% cross, [OutAttribute] int% result)
	{
		pin_ptr<NAMESPACE::Point2D64f> pcross = &cross;
		pin_ptr<int> presult = &result;
		icvGetCrossPieceDirect(*(CvPoint2D64f*)&p_start, *(CvPoint2D64f*)&p_end, a, b, c, (CvPoint2D64f*)pcross, presult);
	}

	/// <summary>
	/// </summary>
	/// <param name="p1_start"></param>
	/// <param name="p1_end"></param>
	/// <param name="p2_start"></param>
	/// <param name="p2_end"></param>
	/// <param name="cross"></param>
	static void GetCrossPiecePiece(NAMESPACE::Point2D64f p1_start, NAMESPACE::Point2D64f p1_end, NAMESPACE::Point2D64f p2_start, NAMESPACE::Point2D64f p2_end, [OutAttribute] NAMESPACE::Point2D64f% cross, [OutAttribute] int% result)
	{
		pin_ptr<NAMESPACE::Point2D64f> pcross = &cross;
		pin_ptr<int> presult = &result;
		icvGetCrossPiecePiece(*(CvPoint2D64f*)&p1_start, *(CvPoint2D64f*)&p1_end, *(CvPoint2D64f*)&p2_start, *(CvPoint2D64f*)&p2_end, (CvPoint2D64f*)pcross, presult);
	}

	/// <summary>
	/// </summary>
	/// <param name="point1"></param>
	/// <param name="point2"></param>
	static void GetPieceLength(NAMESPACE::Point2D64f point1, NAMESPACE::Point2D64f point2, [OutAttribute] double% dist)
	{
		pin_ptr<double> pdist = &dist;
		icvGetPieceLength(*(CvPoint2D64f*)&point1, *(CvPoint2D64f*)&point2, pdist);
	}

	/// <summary>
	/// </summary>
	/// <param name="imageSize"></param>
	/// <param name="a"></param>
	/// <param name="b"></param>
	/// <param name="c"></param>
	/// <param name="start"></param>
	/// <param name="end"></param>
	static void GetCrossRectDirect(NAMESPACE::Size2D32s imageSize, double a, double b, double c, [OutAttribute] NAMESPACE::Point2D64f% start, [OutAttribute] NAMESPACE::Point2D64f% end, [OutAttribute] int% result)
	{
		pin_ptr<NAMESPACE::Point2D64f> pstart = &start;
		pin_ptr<NAMESPACE::Point2D64f> pend = &end;
		pin_ptr<int> presult = &result;
		icvGetCrossRectDirect(*(CvSize*)&imageSize, a, b, c, (CvPoint2D64f*)pstart, (CvPoint2D64f*)pend, presult);
	}

	/// <summary>
	/// </summary>
	/// <param name="point"></param>
	/// <param name="camMatr"></param>
	/// <param name="rotMatr"></param>
	/// <param name="transVect"></param>
	static void ProjectPointToImage(NAMESPACE::Point3D64f point, array<double>^ camMatr, array<double>^ rotMatr, array<double>^ transVect, [OutAttribute] NAMESPACE::Point2D64f% projPoint)
	{
		pin_ptr<double> pcamMatr = &camMatr[0];
		pin_ptr<double> protMatr = &rotMatr[0];
		pin_ptr<double> ptransVect = &transVect[0];
		pin_ptr<NAMESPACE::Point2D64f> pprojPoint = &projPoint;
		icvProjectPointToImage(*(CvPoint3D64f*)&point, (CvMatr64d)pcamMatr, (CvMatr64d)protMatr, (CvVect64d)ptransVect, (CvPoint2D64f*)pprojPoint);
	}

	/// <summary>
	/// </summary>
	/// <param name="imageSize"></param>
	/// <param name="camMatr1"></param>
	/// <param name="rotMatr1"></param>
	/// <param name="transVect1"></param>
	/// <param name="camMatr2"></param>
	/// <param name="rotMatr2"></param>
	/// <param name="transVect2"></param>
	/// <param name="warpSize"></param>
	/// <param name="quad1[4][2]"></param>
	/// <param name="quad2[4][2]"></param>
	/// <param name="fundMatr"></param>
	/// <param name="epipole1"></param>
	static void GetQuadsTransform(NAMESPACE::Size2D32s imageSize, array<double>^ camMatr1, array<double>^ rotMatr1, array<double>^ transVect1, array<double>^ camMatr2, array<double>^ rotMatr2, array<double>^ transVect2, [OutAttribute] NAMESPACE::Size2D32s% warpSize, array<double, 2>^ quad1, array<double, 2>^ quad2, array<double>^ fundMatr, [OutAttribute] NAMESPACE::Point3D64f% epipole1, [OutAttribute] NAMESPACE::Point3D64f% epipole2)
	{
		pin_ptr<double> pcamMatr1 = &camMatr1[0];
		pin_ptr<double> protMatr1 = &rotMatr1[0];
		pin_ptr<double> ptransVect1 = &transVect1[0];
		pin_ptr<double> pcamMatr2 = &camMatr2[0];
		pin_ptr<double> protMatr2 = &rotMatr2[0];
		pin_ptr<double> ptransVect2 = &transVect2[0];
		pin_ptr<NAMESPACE::Size2D32s> pwarpSize = &warpSize;
		pin_ptr<double> pfundMatr = &fundMatr[0];
		pin_ptr<NAMESPACE::Point3D64f> pepipole1 = &epipole1;
		pin_ptr<NAMESPACE::Point3D64f> pepipole2 = &epipole2;

		double _quad1[4][2];
		double _quad2[4][2];
		_quad1[0][0] = quad1[0, 0];
		_quad1[0][1] = quad1[0, 1];
		_quad1[1][0] = quad1[1, 0];
		_quad1[1][1] = quad1[1, 1];
		_quad1[2][0] = quad1[2, 0];
		_quad1[2][1] = quad1[2, 1];
		_quad1[3][0] = quad1[3, 0];
		_quad1[3][1] = quad1[3, 1];
		_quad2[0][0] = quad2[0, 0];
		_quad2[0][1] = quad2[0, 1];
		_quad2[1][0] = quad2[1, 0];
		_quad2[1][1] = quad2[1, 1];
		_quad2[2][0] = quad2[2, 0];
		_quad2[2][1] = quad2[2, 1];
		_quad2[3][0] = quad2[3, 0];
		_quad2[3][1] = quad2[3, 1];
		icvGetQuadsTransform(*(CvSize*)&imageSize, pcamMatr1, protMatr1, ptransVect1, pcamMatr2, protMatr2, ptransVect2, (CvSize*)pwarpSize, _quad1, _quad2, pfundMatr, (CvPoint3D64f*)pepipole1, (CvPoint3D64f*)pepipole2);
		quad1[0, 0] = _quad1[0][0];
		quad1[0, 1] = _quad1[0][1];
		quad1[1, 0] = _quad1[1][0];
		quad1[1, 1] = _quad1[1][1];
		quad1[2, 0] = _quad1[2][0];
		quad1[2, 1] = _quad1[2][1];
		quad1[3, 0] = _quad1[3][0];
		quad1[3, 1] = _quad1[3][1];
		quad2[0, 0] = _quad2[0][0];
		quad2[0, 1] = _quad2[0][1];
		quad2[1, 0] = _quad2[1][0];
		quad2[1, 1] = _quad2[1][1];
		quad2[2, 0] = _quad2[2][0];
		quad2[2, 1] = _quad2[2][1];
		quad2[3, 0] = _quad2[3][0];
		quad2[3, 1] = _quad2[3][1];
	}

	/// <summary>
	/// </summary>
	static void GetQuadsTransformStruct(ManagedStereoCamera^ stereoCamera)
	{
		icvGetQuadsTransformStruct(stereoCamera->ToCvStereoCameraPointer());
	}

	/// <summary>
	/// </summary>
	static void ComputeStereoParamsForCameras(ManagedStereoCamera^ stereoCamera)
	{
		icvComputeStereoParamsForCameras(stereoCamera->ToCvStereoCameraPointer());
	}

	/// <summary>
	/// </summary>
	/// <param name="areaLineCoef1"></param>
	/// <param name="areaLineCoef2"></param>
	/// <param name="epipole"></param>
	/// <param name="imageSize"></param>
	/// <param name="point11"></param>
	/// <param name="point12"></param>
	/// <param name="point21"></param>
	/// <param name="point22"></param>
	static void GetCutPiece(array<double>^ areaLineCoef1, array<double>^ areaLineCoef2, NAMESPACE::Point2D64f epipole, NAMESPACE::Size2D32s imageSize, [OutAttribute] NAMESPACE::Point2D64f% point11, [OutAttribute] NAMESPACE::Point2D64f% point12, [OutAttribute] NAMESPACE::Point2D64f% point21, [OutAttribute] NAMESPACE::Point2D64f% point22, [OutAttribute] int% result)
	{
		pin_ptr<double> pareaLineCoef1 = &areaLineCoef1[0];
		pin_ptr<double> pareaLineCoef2 = &areaLineCoef2[0];
		pin_ptr<NAMESPACE::Point2D64f> ppoint11 = &point11;
		pin_ptr<NAMESPACE::Point2D64f> ppoint12 = &point12;
		pin_ptr<NAMESPACE::Point2D64f> ppoint21 = &point21;
		pin_ptr<NAMESPACE::Point2D64f> ppoint22 = &point22;
		pin_ptr<int> presult = &result;
		icvGetCutPiece((CvVect64d)pareaLineCoef1, (CvVect64d)pareaLineCoef2, *(CvPoint2D64f*)&epipole, *(CvSize*)&imageSize, (CvPoint2D64f*)ppoint11, (CvPoint2D64f*)ppoint12, (CvPoint2D64f*)ppoint21, (CvPoint2D64f*)ppoint22, presult);
	}

	/// <summary>
	/// </summary>
	/// <param name="basePoint"></param>
	/// <param name="point1"></param>
	/// <param name="point2"></param>
	static void GetMiddleAnglePoint(NAMESPACE::Point2D64f basePoint, NAMESPACE::Point2D64f point1, NAMESPACE::Point2D64f point2, [OutAttribute] NAMESPACE::Point2D64f% midPoint)
	{
		pin_ptr<NAMESPACE::Point2D64f> pmidPoint = &midPoint;
		icvGetMiddleAnglePoint(*(CvPoint2D64f*)&basePoint, *(CvPoint2D64f*)&point1, *(CvPoint2D64f*)&point2, (CvPoint2D64f*)pmidPoint);
	}

	/// <summary>
	/// </summary>
	/// <param name="direct"></param>
	/// <param name="point"></param>
	static void GetNormalDirect(array<double>^ direct, NAMESPACE::Point2D64f point, array<double>^ normDirect)
	{
		pin_ptr<double> pdirect = &direct[0];
		pin_ptr<double> pnormDirect = &normDirect[0];
		icvGetNormalDirect((CvVect64d)pdirect, *(CvPoint2D64f*)&point, (CvVect64d)pnormDirect);
	}

	/// <summary>
	/// </summary>
	/// <param name="basePoint"></param>
	/// <param name="point1"></param>
	/// <returns></returns>
	static double GetVect(NAMESPACE::Point2D64f basePoint, NAMESPACE::Point2D64f point1, NAMESPACE::Point2D64f point2)
	{
		return icvGetVect(*(CvPoint2D64f*)&basePoint, *(CvPoint2D64f*)&point1, *(CvPoint2D64f*)&point2);
	}

	/// <summary>
	/// </summary>
	/// <param name="point"></param>
	/// <param name="lineCoeff"></param>
	static void ProjectPointToDirect(NAMESPACE::Point2D64f point, array<double>^ lineCoeff, [OutAttribute] NAMESPACE::Point2D64f% projectPoint)
	{
		pin_ptr<double> plineCoeff = &lineCoeff[0];
		pin_ptr<NAMESPACE::Point2D64f> pprojectPoint = &projectPoint;
		icvProjectPointToDirect(*(CvPoint2D64f*)&point, (CvVect64d)plineCoeff, (CvPoint2D64f*)pprojectPoint);
	}

	/// <summary>
	/// </summary>
	/// <param name="point"></param>
	/// <param name="lineCoef"></param>
	static void GetDistanceFromPointToDirect(NAMESPACE::Point2D64f point, array<double>^ lineCoef, [OutAttribute] double% dist)
	{
		pin_ptr<double> plineCoef = &lineCoef[0];
		pin_ptr<double> pdist = &dist;
		icvGetDistanceFromPointToDirect(*(CvPoint2D64f*)&point, (CvVect64d)plineCoef, pdist);
	}

	/// <summary>
	/// </summary>
	/// <param name="src"></param>
	/// <param name="dst"></param>
	/// <param name="desired_depth"></param>
	/// <returns></returns>
	static ManagedImage^ CreateIsometricImage(ManagedImage^ src, ManagedImage^ dst, PixelDepth desired_depth, int desired_num_channels)
	{
		return gcnew ManagedImage(icvCreateIsometricImage(src->ToIplImagePointer(), dst->ToIplImagePointer(), (int)desired_depth, desired_num_channels), true);
	}

	/// <summary>
	/// </summary>
	/// <param name="frame"></param>
	/// <param name="fieldEven"></param>
	static void DeInterlace(ManagedArr^ frame, ManagedArr^ fieldEven, ManagedArr^ fieldOdd)
	{
		cvDeInterlace(frame->ToCvArrPointer(), fieldEven->ToCvArrPointer(), fieldOdd->ToCvArrPointer());
	}

	/// <summary>
	/// finds correspondence between two contours
	/// </summary>
	/// <param name="frame"></param>
	/// <param name="fieldEven"></param>
	static ManagedSeq^ CalcContoursCorrespondence(ManagedSeq^ contour1, ManagedSeq^ contour2, ManagedMemStorage^ storage)
	{
		throw gcnew System::NotSupportedException();
		// return gcnew ManagedSeq(cvCalcContoursCorrespondence(contour1->ToCvSeqPointer(), contour2->ToCvSeqPointer(), storage->ToCvMemStoragePointer()));
	}

	/// <summary>
	/// morphs contours using the pre-calculated correspondence
	/// alpha=0 ~ contour1, alpha=1 ~ contour2
	/// </summary>
	/// <param name="frame"></param>
	/// <param name="fieldEven"></param>
	static ManagedSeq^ MorphContours(ManagedSeq^ contour1, ManagedSeq^ contour2, ManagedSeq^ corr, double alpha, ManagedMemStorage^ storage )
	{
		throw gcnew System::NotSupportedException();
		// return gcnew ManagedSeq(cvMorphContours(contour1->ToCvSeqPointer(), contour2->ToCvSeqPointer(), corr->ToCvSeqPointer(), alpha, storage->ToCvMemStoragePointer()));
	}

	/// <summary>
	/// </summary>
	/// <param name="srcImage"></param>
	/// <param name="stepMagnitude"></param>
	/// <param name="stepDirections"></param>
	/// <param name="numStepDirections"></param>
	/// <returns></returns>
	static ManagedGLCM^ CreateGLCM(ManagedImage^ srcImage, int stepMagnitude, array<int>^ stepDirections, int numStepDirections, GLCMOptimizationType optimizationType)
	{
		pin_ptr<int> pstepDirections = &stepDirections[0];
		return gcnew ManagedGLCM(cvCreateGLCM(srcImage->ToIplImagePointer(), stepMagnitude, pstepDirections, numStepDirections, (int)optimizationType), true);
	}

	/// <summary>
	/// </summary>
	/// <param name="srcImage"></param>
	/// <param name="stepMagnitude"></param>
	/// <param name="stepDirections"></param>
	/// <returns></returns>
	static ManagedGLCM^ CreateGLCM(ManagedImage^ srcImage, int stepMagnitude, array<int>^ stepDirections, int numStepDirections)
	{
		pin_ptr<int> pstepDirections = &stepDirections[0];
		return gcnew ManagedGLCM(cvCreateGLCM(srcImage->ToIplImagePointer(), stepMagnitude, pstepDirections, numStepDirections), true);
	}

	/// <summary>
	/// </summary>
	/// <param name="srcImage"></param>
	/// <param name="stepMagnitude"></param>
	/// <returns></returns>
	static ManagedGLCM^ CreateGLCM(ManagedImage^ srcImage, int stepMagnitude, array<int>^ stepDirections)
	{
		pin_ptr<int> pstepDirections = &stepDirections[0];
		return gcnew ManagedGLCM(cvCreateGLCM(srcImage->ToIplImagePointer(), stepMagnitude, pstepDirections), true);
	}

	/// <summary>
	/// </summary>
	/// <param name="srcImage"></param>
	/// <returns></returns>
	static ManagedGLCM^ CreateGLCM(ManagedImage^ srcImage, int stepMagnitude)
	{
		return gcnew ManagedGLCM(cvCreateGLCM(srcImage->ToIplImagePointer(), stepMagnitude), true);
	}

	/// <summary>
	/// </summary>
	/// <param name="GLCM"></param>
	static void ReleaseGLCM(ManagedGLCM^ GLCM, GLCMReleaseFlag flag)
	{
		CvGLCM* pGLCM = GLCM->ToCvGLCMPointer();
		cvReleaseGLCM(&pGLCM, (int)flag);
		GLCM->m_pHandle = pGLCM;
	}

	/// <summary>
	/// </summary>
	static void ReleaseGLCM(ManagedGLCM^ GLCM)
	{
		CvGLCM* pGLCM = GLCM->ToCvGLCMPointer();
		cvReleaseGLCM(&pGLCM);
		GLCM->m_pHandle = pGLCM;
	}

	/// <summary>
	/// </summary>
	/// <param name="destGLCM"></param>
	static void CreateGLCMDescriptors(ManagedGLCM^ destGLCM, GLCMDescOptimizationType descriptorOptimizationType)
	{
		cvCreateGLCMDescriptors(destGLCM->ToCvGLCMPointer(), (int)descriptorOptimizationType);
	}

	/// <summary>
	/// </summary>
	static void CreateGLCMDescriptors(ManagedGLCM^ destGLCM)
	{
		cvCreateGLCMDescriptors(destGLCM->ToCvGLCMPointer());
	}

	/// <summary>
	/// </summary>
	/// <param name="GLCM"></param>
	/// <param name="step"></param>
	/// <returns></returns>
	static double GetGLCMDescriptor(ManagedGLCM^ GLCM, int step, GLCMDescType descriptor)
	{
		return cvGetGLCMDescriptor(GLCM->ToCvGLCMPointer(), step, (int)descriptor);
	}

	/// <summary>
	/// </summary>
	/// <param name="GLCM"></param>
	/// <param name="descriptor"></param>
	/// <param name="average"></param>
	static void GetGLCMDescriptorStatistics(ManagedGLCM^ GLCM, GLCMDescType descriptor, [OutAttribute] double% average, [OutAttribute] double% standardDeviation)
	{
		pin_ptr<double> paverage = &average;
		pin_ptr<double> pstandardDeviation = &standardDeviation;
		cvGetGLCMDescriptorStatistics(GLCM->ToCvGLCMPointer(), (int)descriptor, paverage, pstandardDeviation);
	}

	/// <summary>
	/// </summary>
	/// <param name="GLCM"></param>
	/// <returns></returns>
	static ManagedImage^ CreateGLCMImage(ManagedGLCM^ GLCM, int step)
	{
		return gcnew ManagedImage(cvCreateGLCMImage(GLCM->ToCvGLCMPointer(), step), true);
	}

	/// <summary>
	/// </summary>
	/// <param name="pFaceTracking"></param>
	/// <param name="imgGray"></param>
	/// <param name="pRects"></param>
	/// <returns></returns>
	static ManagedFaceTracker^ InitFaceTracker(ManagedFaceTracker^ pFaceTracking, ManagedImage^ imgGray, array<NAMESPACE::Rect>^ pRects, int nRects)
	{
		pin_ptr<NAMESPACE::Rect> ppRects = &pRects[0];
		return gcnew ManagedFaceTracker(cvInitFaceTracker(pFaceTracking->ToCvFaceTrackerPointer(), imgGray->ToIplImagePointer(), (CvRect*)ppRects, nRects), true);
	}

	/// <summary>
	/// </summary>
	/// <param name="pFaceTracker"></param>
	/// <param name="imgGray"></param>
	/// <param name="pRects"></param>
	/// <param name="nRects"></param>
	/// <param name="ptRotate"></param>
	/// <returns></returns>
	static int TrackFace(ManagedFaceTracker^ pFaceTracker, ManagedImage^ imgGray, array<NAMESPACE::Rect>^ pRects, int nRects, [OutAttribute] NAMESPACE::Point2D32s% ptRotate, [OutAttribute] double% dbAngleRotate)
	{
		pin_ptr<NAMESPACE::Rect> ppRects = &pRects[0];
		pin_ptr<NAMESPACE::Point2D32s> pptRotate = &ptRotate;
		pin_ptr<double> pdbAngleRotate = &dbAngleRotate;
		return cvTrackFace(pFaceTracker->ToCvFaceTrackerPointer(), imgGray->ToIplImagePointer(), (CvRect*)ppRects, nRects, (CvPoint*)pptRotate, pdbAngleRotate);
	}

	/// <summary>
	/// </summary>
	static void ReleaseFaceTracker(ManagedFaceTracker^% ppFaceTracker)
	{
		CvFaceTracker* pFaceTracker = ppFaceTracker->ToCvFaceTrackerPointer();
		cvReleaseFaceTracker(&pFaceTracker);
		ppFaceTracker->m_pHandle = pFaceTracker;
	}

	/// <summary>
	/// </summary>
	static ManagedSeq^ FindFace(ManagedImage^ Image, ManagedMemStorage^ storage)
	{
		throw gcnew System::NotSupportedException();
		//return gcnew ManagedSeq(cvFindFace(Image->ToIplImagePointer(), storage->ToCvMemStoragePointer()));
	}

	/// <summary>
	/// </summary>
	static ManagedSeq^ PostBoostingFindFace(ManagedImage^ Image, ManagedMemStorage^ storage)
	{
		throw gcnew System::NotSupportedException();
		//return gcnew ManagedSeq(cvPostBoostingFindFace(Image->ToIplImagePointer(), storage->ToCvMemStoragePointer()));
	}

	/// <summary>
	/// </summary>
	/// <param name="num_cameras"></param>
	/// <param name="camera_intrinsics[]"></param>
	/// <param name="etalon_size"></param>
	/// <param name="square_size"></param>
	/// <param name="samples[]"></param>
	/// <returns></returns>
	static bool TrackerCalibrateCameras_3D(int num_cameras, array<TrackerCameraIntrinsics3D>^ camera_intrinsics, NAMESPACE::Size2D32s etalon_size, float square_size, array<ManagedImage^>^ samples, array<TrackerCameraInfo3D>^ camera_info)
	{
		pin_ptr<TrackerCameraIntrinsics3D> pcamera_intrinsics = &camera_intrinsics[0];
		pin_ptr<TrackerCameraInfo3D> pcamera_info = &camera_info[0];
		vector<IplImage*> vsamples(num_cameras);
		for(int i = 0; i < num_cameras; i++)
		{
			vsamples[i] = samples[i]->ToIplImagePointer();
		}
		return 0 != cv3dTrackerCalibrateCameras(num_cameras, (Cv3dTrackerCameraIntrinsics*)pcamera_intrinsics, *(CvSize*)&etalon_size, square_size, &vsamples[0], (Cv3dTrackerCameraInfo*)pcamera_info);
	}

	/// <summary>
	/// size is num_cameras
	/// </summary>
	/// <param name="num_cameras"></param>
	/// <param name="num_objects"></param>
	/// <param name="camera_info[]"></param>
	/// <param name="tracking_info[]"></param>
	/// <returns></returns>
	static int TrackerLocateObjects_3D(int num_cameras, int num_objects, array<NAMESPACE::TrackerCameraInfo3D>^ camera_info, array<NAMESPACE::Tracker2DTrackedObject3D>^ tracking_info, array<NAMESPACE::TrackerTrackedObject3D>^ tracked_objects)
	{
		pin_ptr<NAMESPACE::TrackerCameraInfo3D> pcamera_info = &camera_info[0];
		pin_ptr<NAMESPACE::Tracker2DTrackedObject3D> ptracking_info = &tracking_info[0];
		pin_ptr<NAMESPACE::TrackerTrackedObject3D> ptracked_objects = &tracked_objects[0];
		return cv3dTrackerLocateObjects(num_cameras, num_objects, (Cv3dTrackerCameraInfo*)pcamera_info, (Cv3dTracker2dTrackedObject*)ptracking_info, (Cv3dTrackerTrackedObject*)ptracked_objects);
	}

	/// <summary>
	/// Computes Voronoi Diagram for given polygons with holes
	/// </summary>
	/// <param name="ContourSeq"></param>
	/// <param name="VoronoiDiagram"></param>
	/// <param name="VoronoiStorage"></param>
	/// <param name="contour_type"></param>
	/// <param name="contour_orientation"></param>
	/// <returns></returns>
	static int VoronoiDiagramFromContour(ManagedSeq^ ContourSeq, [OutAttribute] ManagedVoronoiDiagram2D^% VoronoiDiagram, ManagedMemStorage^ VoronoiStorage, NAMESPACE::LeeParameters contour_type, int contour_orientation, int attempt_number)
	{
		CvVoronoiDiagram2D* pVoronoiDiagram = NULL;
		int nRet = cvVoronoiDiagramFromContour(ContourSeq->ToCvSeqPointer(), &pVoronoiDiagram, VoronoiStorage->ToCvMemStoragePointer(), *(CvLeeParameters*)&contour_type, contour_orientation, attempt_number);
		VoronoiDiagram = gcnew ManagedVoronoiDiagram2D(pVoronoiDiagram);
		return nRet;
	}

	/// <summary>
	/// Computes Voronoi Diagram for given polygons with holes
	/// </summary>
	/// <param name="ContourSeq"></param>
	/// <param name="VoronoiDiagram"></param>
	/// <param name="VoronoiStorage"></param>
	/// <param name="contour_type"></param>
	/// <returns></returns>
	static int VoronoiDiagramFromContour(ManagedSeq^ ContourSeq, [OutAttribute] ManagedVoronoiDiagram2D^% VoronoiDiagram, ManagedMemStorage^ VoronoiStorage, NAMESPACE::LeeParameters contour_type, int contour_orientation)
	{
		CvVoronoiDiagram2D* pVoronoiDiagram = NULL;
		int nRet = cvVoronoiDiagramFromContour(ContourSeq->ToCvSeqPointer(), &pVoronoiDiagram, VoronoiStorage->ToCvMemStoragePointer(), *(CvLeeParameters*)&contour_type, contour_orientation);
		VoronoiDiagram = gcnew ManagedVoronoiDiagram2D(pVoronoiDiagram);
		return nRet;
	}

	/// <summary>
	/// Computes Voronoi Diagram for given polygons with holes
	/// </summary>
	/// <param name="ContourSeq"></param>
	/// <param name="VoronoiDiagram"></param>
	/// <param name="VoronoiStorage"></param>
	/// <returns></returns>
	static int VoronoiDiagramFromContour(ManagedSeq^ ContourSeq, [OutAttribute] ManagedVoronoiDiagram2D^% VoronoiDiagram, ManagedMemStorage^ VoronoiStorage, NAMESPACE::LeeParameters contour_type)
	{
		CvVoronoiDiagram2D* pVoronoiDiagram = NULL;
		int nRet = cvVoronoiDiagramFromContour(ContourSeq->ToCvSeqPointer(), &pVoronoiDiagram, VoronoiStorage->ToCvMemStoragePointer(), *(CvLeeParameters*)&contour_type);
		VoronoiDiagram = gcnew ManagedVoronoiDiagram2D(pVoronoiDiagram);
		return nRet;
	}

	/// <summary>
	/// Computes Voronoi Diagram for given polygons with holes
	/// </summary>
	/// <param name="ContourSeq"></param>
	/// <param name="VoronoiDiagram"></param>
	/// <returns></returns>
	static int VoronoiDiagramFromContour(ManagedSeq^ ContourSeq, [OutAttribute] ManagedVoronoiDiagram2D^% VoronoiDiagram, ManagedMemStorage^ VoronoiStorage)
	{
		CvVoronoiDiagram2D* pVoronoiDiagram = NULL;
		int nRet = cvVoronoiDiagramFromContour(ContourSeq->ToCvSeqPointer(), &pVoronoiDiagram, VoronoiStorage->ToCvMemStoragePointer());
		VoronoiDiagram = gcnew ManagedVoronoiDiagram2D(pVoronoiDiagram);
		return nRet;
	}

	/// <summary>
	/// Computes Voronoi Diagram for domains in given image
	/// </summary>
	/// <param name="pImage"></param>
	/// <param name="ContourSeq"></param>
	/// <param name="VoronoiDiagram"></param>
	/// <param name="VoronoiStorage"></param>
	/// <param name="regularization_method"></param>
	/// <returns></returns>
	static int VoronoiDiagramFromImage(ManagedImage^ pImage, [OutAttribute] ManagedSeq^% ContourSeq, [OutAttribute] ManagedVoronoiDiagram2D^% VoronoiDiagram, ManagedMemStorage^ VoronoiStorage, NAMESPACE::LeeParameters regularization_method, float approx_precision)
	{
		CvSeq* pContourSeq = NULL;
		CvVoronoiDiagram2D* pVoronoiDiagram = NULL;
		int nRet = cvVoronoiDiagramFromImage(pImage->ToIplImagePointer(), &pContourSeq, &pVoronoiDiagram, VoronoiStorage->ToCvMemStoragePointer(), *(CvLeeParameters*)&regularization_method, approx_precision);
		ContourSeq = gcnew ManagedSeq(pContourSeq);
		VoronoiDiagram = gcnew ManagedVoronoiDiagram2D(pVoronoiDiagram);
		return nRet;
	}

	/// <summary>
	/// Computes Voronoi Diagram for domains in given image
	/// </summary>
	/// <param name="pImage"></param>
	/// <param name="ContourSeq"></param>
	/// <param name="VoronoiDiagram"></param>
	/// <param name="VoronoiStorage"></param>
	/// <returns></returns>
	static int VoronoiDiagramFromImage(ManagedImage^ pImage, [OutAttribute] ManagedSeq^% ContourSeq, [OutAttribute] ManagedVoronoiDiagram2D^% VoronoiDiagram, ManagedMemStorage^ VoronoiStorage, NAMESPACE::LeeParameters regularization_method)
	{
		CvSeq* pContourSeq = NULL;
		CvVoronoiDiagram2D* pVoronoiDiagram = NULL;
		int nRet = cvVoronoiDiagramFromImage(pImage->ToIplImagePointer(), &pContourSeq, &pVoronoiDiagram, VoronoiStorage->ToCvMemStoragePointer(), *(CvLeeParameters*)&regularization_method);
		ContourSeq = gcnew ManagedSeq(pContourSeq);
		VoronoiDiagram = gcnew ManagedVoronoiDiagram2D(pVoronoiDiagram);
		return nRet;
	}

	/// <summary>
	/// Computes Voronoi Diagram for domains in given image
	/// </summary>
	/// <param name="pImage"></param>
	/// <param name="ContourSeq"></param>
	/// <param name="VoronoiDiagram"></param>
	/// <returns></returns>
	static int VoronoiDiagramFromImage(ManagedImage^ pImage, [OutAttribute] ManagedSeq^% ContourSeq, [OutAttribute] ManagedVoronoiDiagram2D^% VoronoiDiagram, ManagedMemStorage^ VoronoiStorage)
	{
		CvSeq* pContourSeq = NULL;
		CvVoronoiDiagram2D* pVoronoiDiagram = NULL;
		int nRet = cvVoronoiDiagramFromImage(pImage->ToIplImagePointer(), &pContourSeq, &pVoronoiDiagram, VoronoiStorage->ToCvMemStoragePointer());
		ContourSeq = gcnew ManagedSeq(pContourSeq);
		VoronoiDiagram = gcnew ManagedVoronoiDiagram2D(pVoronoiDiagram);
		return nRet;
	}

	/// <summary>
	/// Deallocates the storage
	/// </summary>
	/// <param name="VoronoiDiagram"></param>
	static void ReleaseVoronoiStorage(ManagedVoronoiDiagram2D^ VoronoiDiagram, ManagedMemStorage^% pVoronoiStorage)
	{
		CvMemStorage* ppVoronoiStorage = pVoronoiStorage->ToCvMemStoragePointer();
		cvReleaseVoronoiStorage(VoronoiDiagram->ToCvVoronoiDiagram2DPointer(), &ppVoronoiStorage);
		pVoronoiStorage->m_pHandle = ppVoronoiStorage;
	}

	/// <summary>
	/// Computes hybrid model from Voronoi Diagram
	/// </summary>
	/// <param name="VoronoiDiagram"></param>
	/// <returns></returns>
	static ManagedGraph^ LinearContorModelFromVoronoiDiagram(ManagedVoronoiDiagram2D^ VoronoiDiagram, float maxWidth)
	{
		return gcnew ManagedGraph(cvLinearContorModelFromVoronoiDiagram(VoronoiDiagram->ToCvVoronoiDiagram2DPointer(), maxWidth));
	}

	/// <summary>
	/// Releases hybrid model storage
	/// </summary>
	/// <returns></returns>
	static int ReleaseLinearContorModelStorage(ManagedGraph^% Graph)
	{
		CvGraph* pGraph = Graph->ToCvGraphPointer();
		return cvReleaseLinearContorModelStorage(&pGraph);
		Graph->m_pHandle = pGraph;
	}

	/// <summary>
	/// two stereo-related functions
	/// </summary>
	/// <param name="size"></param>
	/// <param name="vertex[4]"></param>
	/// <param name="matrix[3][3]"></param>
	static void InitPerspectiveTransform(NAMESPACE::Size2D32s size, array<NAMESPACE::Point2D32f>^ vertex, [OutAttribute] array<double, 2>^% matrix, ManagedArr^ rectMap)
	{
		double _matrix[3][3] = {0};
		pin_ptr<NAMESPACE::Point2D32f> pvertex = &vertex[0];
		cvInitPerspectiveTransform(*(CvSize*)&size, (CvPoint2D32f*)pvertex, _matrix, rectMap->ToCvArrPointer());
		matrix = gcnew array<double, 2>(3, 3);
		matrix[0, 0] = _matrix[0][0];
		matrix[0, 1] = _matrix[0][1];
		matrix[0, 2] = _matrix[0][2];
		matrix[1, 0] = _matrix[1][0];
		matrix[1, 1] = _matrix[1][1];
		matrix[1, 2] = _matrix[1][2];
		matrix[2, 0] = _matrix[2][0];
		matrix[2, 1] = _matrix[2][1];
		matrix[2, 2] = _matrix[2][2];
	}

	/// <summary>
	/// Finds ending points of scanlines on left and right images of stereo-pair
	/// </summary>
	/// <param name="matrix"></param>
	/// <param name="img_size"></param>
	/// <param name="scanlines1"></param>
	/// <param name="scanlines2"></param>
	/// <param name="lengths1"></param>
	/// <param name="lengths2"></param>
	static void MakeScanlines(Matrix3% matrix, NAMESPACE::Size2D32s img_size, array<int>^ scanlines1, array<int>^ scanlines2, array<int>^ lengths1, array<int>^ lengths2, [OutAttribute] int% line_count)
	{
		pin_ptr<Matrix3> pmatrix = &matrix;
		pin_ptr<int> pscanlines1 = &scanlines1[0];
		pin_ptr<int> pscanlines2 = &scanlines2[0];
		pin_ptr<int> plengths1 = &lengths1[0];
		pin_ptr<int> plengths2 = &lengths2[0];
		pin_ptr<int> pline_count = &line_count;
		cvMakeScanlines((CvMatrix3*)pmatrix, *(CvSize*)&img_size, pscanlines1, pscanlines2, plengths1, plengths2, pline_count);
	}

	/// <summary>
	/// Grab pixel values from scanlines and stores them sequentially
	/// (some sort of perspective image transform)
	/// </summary>
	/// <param name="line_count"></param>
	/// <param name="img"></param>
	/// <param name="dst"></param>
	/// <param name="dst_nums"></param>
	static void PreWarpImage(int line_count, ManagedImage^ img, array<uchar>^ dst, array<int>^ dst_nums, array<int>^ scanlines)
	{
		pin_ptr<uchar> pdst = &dst[0];
		pin_ptr<int> pdst_nums = &dst_nums[0];
		pin_ptr<int> pscanlines = &scanlines[0];
		cvPreWarpImage(line_count, img->ToIplImagePointer(), pdst, pdst_nums, pscanlines);
	}

	/// <summary>
	/// Approximate each grabbed scanline by a sequence of runs
	/// (lossy run-length compression)
	/// </summary>
	/// <param name="line_count"></param>
	/// <param name="prewarp1"></param>
	/// <param name="prewarp2"></param>
	/// <param name="line_lengths1"></param>
	/// <param name="line_lengths2"></param>
	/// <param name="runs1"></param>
	/// <param name="runs2"></param>
	/// <param name="num_runs1"></param>
	static void FindRuns(int line_count, array<uchar>^ prewarp1, array<uchar>^ prewarp2, array<int>^ line_lengths1, array<int>^ line_lengths2, array<int>^ runs1, array<int>^ runs2, array<int>^ num_runs1, array<int>^ num_runs2)
	{
		pin_ptr<uchar> pprewarp1 = &prewarp1[0];
		pin_ptr<uchar> pprewarp2 = &prewarp2[0];
		pin_ptr<int> pline_lengths1 = &line_lengths1[0];
		pin_ptr<int> pline_lengths2 = &line_lengths2[0];
		pin_ptr<int> pruns1 = &runs1[0];
		pin_ptr<int> pruns2 = &runs2[0];
		pin_ptr<int> pnum_runs1 = &num_runs1[0];
		pin_ptr<int> pnum_runs2 = &num_runs2[0];
		cvFindRuns(line_count, pprewarp1, pprewarp2, pline_lengths1, pline_lengths2, pruns1, pruns2, pnum_runs1, pnum_runs2);
	}

	/// <summary>
	/// Compares two sets of compressed scanlines
	/// </summary>
	/// <param name="line_count"></param>
	/// <param name="first"></param>
	/// <param name="first_runs"></param>
	/// <param name="second"></param>
	/// <param name="second_runs"></param>
	/// <param name="first_corr"></param>
	static void DynamicCorrespondMulti(int line_count, array<int>^ first, array<int>^ first_runs, array<int>^ second, array<int>^ second_runs, array<int>^ first_corr, array<int>^ second_corr)
	{
		pin_ptr<int> pfirst = &first[0];
		pin_ptr<int> pfirst_runs = &first_runs[0];
		pin_ptr<int> psecond = &second[0];
		pin_ptr<int> psecond_runs = &second_runs[0];
		pin_ptr<int> pfirst_corr = &first_corr[0];
		pin_ptr<int> psecond_corr = &second_corr[0];
		cvDynamicCorrespondMulti(line_count, pfirst, pfirst_runs, psecond, psecond_runs, pfirst_corr, psecond_corr);
	}

	/// <summary>
	/// Finds scanline ending coordinates for some intermediate "virtual" camera position
	/// </summary>
	/// <param name="scanlines1"></param>
	/// <param name="scanlines2"></param>
	/// <param name="scanlinesA"></param>
	/// <param name="lengths"></param>
	/// <param name="line_count"></param>
	static void MakeAlphaScanlines(array<int>^ scanlines1, array<int>^ scanlines2, array<int>^ scanlinesA, array<int>^ lengths, int line_count, float alpha)
	{
		pin_ptr<int> pscanlines1 = &scanlines1[0];
		pin_ptr<int> pscanlines2 = &scanlines2[0];
		pin_ptr<int> pscanlinesA = &scanlinesA[0];
		pin_ptr<int> plengths = &lengths[0];
		cvMakeAlphaScanlines(pscanlines1, pscanlines2, pscanlinesA, plengths, line_count, alpha);
	}

	/// <summary>
	/// Blends data of the left and right image scanlines to get
	/// pixel values of "virtual" image scanlines
	/// </summary>
	/// <param name="line_count"></param>
	/// <param name="first_pix"></param>
	/// <param name="first_num"></param>
	/// <param name="second_pix"></param>
	/// <param name="second_num"></param>
	/// <param name="dst_pix"></param>
	/// <param name="dst_num"></param>
	/// <param name="alpha"></param>
	/// <param name="first"></param>
	/// <param name="first_runs"></param>
	/// <param name="second"></param>
	/// <param name="second_runs"></param>
	/// <param name="first_corr"></param>
	static void MorphEpilinesMulti(int line_count, array<uchar>^ first_pix, array<int>^ first_num, array<uchar>^ second_pix, array<int>^ second_num, array<uchar>^ dst_pix, array<int>^ dst_num, float alpha, array<int>^ first, array<int>^ first_runs, array<int>^ second, array<int>^ second_runs, array<int>^ first_corr, array<int>^ second_corr)
	{
		pin_ptr<uchar> pfirst_pix = &first_pix[0];
		pin_ptr<int> pfirst_num = &first_num[0];
		pin_ptr<uchar> psecond_pix = &second_pix[0];
		pin_ptr<int> psecond_num = &second_num[0];
		pin_ptr<uchar> pdst_pix = &dst_pix[0];
		pin_ptr<int> pdst_num = &dst_num[0];
		pin_ptr<int> pfirst = &first[0];
		pin_ptr<int> pfirst_runs = &first_runs[0];
		pin_ptr<int> psecond = &second[0];
		pin_ptr<int> psecond_runs = &second_runs[0];
		pin_ptr<int> pfirst_corr = &first_corr[0];
		pin_ptr<int> psecond_corr = &second_corr[0];
		cvMorphEpilinesMulti(line_count, pfirst_pix, pfirst_num, psecond_pix, psecond_num, pdst_pix, pdst_num, alpha, pfirst, pfirst_runs, psecond, psecond_runs, pfirst_corr, psecond_corr);
	}

	/// <summary>
	/// Does reverse warping of the morphing result to make
	/// it fill the destination image rectangle
	/// </summary>
	/// <param name="line_count"></param>
	/// <param name="src"></param>
	/// <param name="src_nums"></param>
	/// <param name="img"></param>
	static void PostWarpImage(int line_count, array<uchar>^ src, array<int>^ src_nums, ManagedImage^ img, array<int>^ scanlines)
	{
		pin_ptr<uchar> psrc = &src[0];
		pin_ptr<int> psrc_nums = &src_nums[0];
		pin_ptr<int> pscanlines = &scanlines[0];
		cvPostWarpImage(line_count, psrc, psrc_nums, img->ToIplImagePointer(), pscanlines);
	}

	/// <summary>
	/// Deletes Moire (missed pixels that appear due to discretization)
	/// </summary>
	static void DeleteMoire(ManagedImage^ img)
	{
		cvDeleteMoire(img->ToIplImagePointer());
	}

	/// <summary>
	/// Performs FG post-processing using segmentation
	/// (all pixels of a region will be classified as foreground if majority of pixels of the region are FG).
	/// parameters:
	/// segments - pointer to result of segmentation (for example MeanShiftSegmentation)
	/// bg_model - pointer to CvBGStatModel structure
	/// </summary>
	/// <param name="segments"></param>
	static void RefineForegroundMaskBySegm(ManagedSeq^ segments, ManagedBGStatModel^ bg_model)
	{
		cvRefineForegroundMaskBySegm(segments->ToCvSeqPointer(), bg_model->ToCvBGStatModelPointer());
	}

	/// <summary>
	/// Common use change detection function
	/// </summary>
	/// <param name="prev_frame"></param>
	/// <param name="curr_frame"></param>
	/// <returns></returns>
	static int ChangeDetection(ManagedImage^ prev_frame,ManagedImage^ curr_frame, ManagedImage^ change_mask)
	{
		return cvChangeDetection(prev_frame->ToIplImagePointer(), curr_frame->ToIplImagePointer(), change_mask->ToIplImagePointer());
	}

	/// <summary>
	/// Creates FGD model
	/// </summary>
	/// <param name="first_frame"></param>
	/// <returns></returns>
	static ManagedBGStatModel^ CreateFGDStatModel(ManagedImage^ first_frame, FGDStatModelParams% parameters)
	{
		pin_ptr<FGDStatModelParams> pparameters = &parameters;
		return gcnew ManagedBGStatModel(cvCreateFGDStatModel(first_frame->ToIplImagePointer(), (CvFGDStatModelParams*)pparameters), true);
	}

	/// <summary>
	/// Creates FGD model
	/// </summary>
	/// <returns></returns>
	static ManagedBGStatModel^ CreateFGDStatModel(ManagedImage^ first_frame)
	{
		return gcnew ManagedBGStatModel(cvCreateFGDStatModel(first_frame->ToIplImagePointer()), true);
	}

	/// <summary>
	/// Creates Gaussian mixture background model
	/// </summary>
	/// <param name="first_frame"></param>
	/// <returns></returns>
	static ManagedBGStatModel^ CreateGaussianBGModel(ManagedImage^ first_frame, GaussBGStatModelParams% parameters)
	{
		pin_ptr<GaussBGStatModelParams> pparameters = &parameters;
		return gcnew ManagedBGStatModel(cvCreateGaussianBGModel(first_frame->ToIplImagePointer(), (CvGaussBGStatModelParams*)pparameters), true);
	}

	/// <summary>
	/// Creates Gaussian mixture background model
	/// </summary>
	/// <returns></returns>
	static ManagedBGStatModel^ CreateGaussianBGModel(ManagedImage^ first_frame)
	{
		return gcnew ManagedBGStatModel(cvCreateGaussianBGModel(first_frame->ToIplImagePointer()), true);
	}

	/// <summary>
	/// </summary>
	/// <returns></returns>
	static ManagedBGCodeBookModel^ CreateBGCodeBookModel()
	{
		return gcnew ManagedBGCodeBookModel(cvCreateBGCodeBookModel(), true);
	}

	/// <summary>
	/// </summary>
	static void ReleaseBGCodeBookModel(ManagedBGCodeBookModel^% model)
	{
		CvBGCodeBookModel* pBGCodeBookModel = model->ToCvBGCodeBookModelPointer();
		cvReleaseBGCodeBookModel(&pBGCodeBookModel);
		model->m_pHandle = pBGCodeBookModel;
	}

	/// <summary>
	/// </summary>
	/// <param name="model"></param>
	/// <param name="image"></param>
	/// <param name="roi"></param>
	static void BGCodeBookUpdate(ManagedBGCodeBookModel^ model, ManagedArr^ image, NAMESPACE::Rect roi, ManagedArr^ mask)
	{
		cvBGCodeBookUpdate(model->ToCvBGCodeBookModelPointer(), image->ToCvArrPointer(), *(CvRect*)&roi, mask->ToCvArrPointer());
	}

	/// <summary>
	/// </summary>
	/// <param name="model"></param>
	/// <param name="image"></param>
	static void BGCodeBookUpdate(ManagedBGCodeBookModel^ model, ManagedArr^ image, NAMESPACE::Rect roi)
	{
		cvBGCodeBookUpdate(model->ToCvBGCodeBookModelPointer(), image->ToCvArrPointer(), *(CvRect*)&roi);
	}

	/// <summary>
	/// </summary>
	/// <param name="model"></param>
	static void BGCodeBookUpdate(ManagedBGCodeBookModel^ model, ManagedArr^ image)
	{
		cvBGCodeBookUpdate(model->ToCvBGCodeBookModelPointer(), image->ToCvArrPointer());
	}

	/// <summary>
	/// </summary>
	/// <param name="model"></param>
	/// <param name="image"></param>
	/// <param name="fgmask"></param>
	/// <returns></returns>
	static int BGCodeBookDiff(ManagedBGCodeBookModel^ model, ManagedArr^ image, ManagedArr^ fgmask, NAMESPACE::Rect roi)
	{
		return cvBGCodeBookDiff(model->ToCvBGCodeBookModelPointer(), image->ToCvArrPointer(), fgmask->ToCvArrPointer(), *(CvRect*)&roi);
	}

	/// <summary>
	/// </summary>
	/// <param name="model"></param>
	/// <param name="image"></param>
	/// <returns></returns>
	static int BGCodeBookDiff(ManagedBGCodeBookModel^ model, ManagedArr^ image, ManagedArr^ fgmask)
	{
		return cvBGCodeBookDiff(model->ToCvBGCodeBookModelPointer(), image->ToCvArrPointer(), fgmask->ToCvArrPointer());
	}

	/// <summary>
	/// </summary>
	/// <param name="model"></param>
	/// <param name="staleThresh"></param>
	/// <param name="roi"></param>
	static void BGCodeBookClearStale(ManagedBGCodeBookModel^ model, int staleThresh, NAMESPACE::Rect roi, ManagedArr^ mask)
	{
		cvBGCodeBookClearStale(model->ToCvBGCodeBookModelPointer(), staleThresh, *(CvRect*)&roi, mask->ToCvArrPointer());
	}

	/// <summary>
	/// </summary>
	/// <param name="model"></param>
	/// <param name="staleThresh"></param>
	static void BGCodeBookClearStale(ManagedBGCodeBookModel^ model, int staleThresh, NAMESPACE::Rect roi)
	{
		cvBGCodeBookClearStale(model->ToCvBGCodeBookModelPointer(), staleThresh, *(CvRect*)&roi);
	}

	/// <summary>
	/// </summary>
	/// <param name="model"></param>
	static void BGCodeBookClearStale(ManagedBGCodeBookModel^ model, int staleThresh)
	{
		cvBGCodeBookClearStale(model->ToCvBGCodeBookModelPointer(), staleThresh);
	}

	/// <summary>
	/// </summary>
	/// <param name="fgmask"></param>
	/// <param name="poly1Hull0"></param>
	/// <param name="perimScale"></param>
	/// <param name="storage"></param>
	/// <returns></returns>
	static ManagedSeq^ SegmentFGMask(ManagedArr^ fgmask, int poly1Hull0, float perimScale, ManagedMemStorage^ storage, NAMESPACE::Point2D32s offset)
	{
		return gcnew ManagedSeq(cvSegmentFGMask(fgmask->ToCvArrPointer(), poly1Hull0, perimScale, storage->ToCvMemStoragePointer(), *(CvPoint*)&offset));
	}

	/// <summary>
	/// </summary>
	/// <param name="fgmask"></param>
	/// <param name="poly1Hull0"></param>
	/// <param name="perimScale"></param>
	/// <returns></returns>
	static ManagedSeq^ SegmentFGMask(ManagedArr^ fgmask, int poly1Hull0, float perimScale, ManagedMemStorage^ storage)
	{
		return gcnew ManagedSeq(cvSegmentFGMask(fgmask->ToCvArrPointer(), poly1Hull0, perimScale, storage->ToCvMemStoragePointer()));
	}

	/// <summary>
	/// </summary>
	/// <param name="fgmask"></param>
	/// <param name="poly1Hull0"></param>
	/// <returns></returns>
	static ManagedSeq^ SegmentFGMask(ManagedArr^ fgmask, int poly1Hull0, float perimScale)
	{
		return gcnew ManagedSeq(cvSegmentFGMask(fgmask->ToCvArrPointer(), poly1Hull0, perimScale));
	}

	/// <summary>
	/// </summary>
	/// <param name="fgmask"></param>
	/// <returns></returns>
	static ManagedSeq^ SegmentFGMask(ManagedArr^ fgmask, int poly1Hull0)
	{
		return gcnew ManagedSeq(cvSegmentFGMask(fgmask->ToCvArrPointer(), poly1Hull0));
	}

	/// <summary>
	/// </summary>
	/// <returns></returns>
	static ManagedSeq^ SegmentFGMask(ManagedArr^ fgmask)
	{
		return gcnew ManagedSeq(cvSegmentFGMask(fgmask->ToCvArrPointer()));
	}

//////////////////////////////////////////////////////////////////////////